﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class index : System.Web.UI.Page
{
    BLL.NewsBll nb = new BLL.NewsBll();

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindNews();
        }
    }

    private void BindNews()
    {
        DataTable table = nb.GetTopNews();
        rep_News.DataSource = table;
        rep_News.DataBind();
    }

    protected void rep_News_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        Label label = (Label)e.Item.FindControl("lb_NewsTitle");

        //label.Text += "  " + label.Text.Length;
        if (label.Text.Length > 18)
        {
            string result = label.Text.Substring(0, 17);
            label.Text = result + "...";
        }
    }
}
